<template>
  <view class="pb-10">
    <view class="w100 pl-24 pr-24 pt-12">
      <view class="w100 h-68 br-34 rowsb rowsm pl-42 pr-4 mb-20" style="border: 2rpx solid #4886FF;">
        <input type="text" placeholder="输入搜索" placeholder-class="fs-26 col888" v-model="titleName" @input="handleQuery">
        <view class="w-98 h-60 br-30 rowsc rowsm" style="background: linear-gradient(to bottom,#4897FF,#4878FF);">
          <image src="/static/icon_osbc-1.png" class="w-28 h-28" mode="" ></image>
        </view>
      </view>
      
      <view class="w100 p-all-24 bgff br-20 mb-20 rows rowsm" v-for="(item,index) in list" :key="index" @click="$tools.goNext(`/pages/index/newsDetail?title=${titleType}&id=${item.id}`)">
        <!-- <image :src="item.image" class="w-284 h-182 br-20 mr-32" mode=""></image> -->
        <view class="rowscl w100">
          <view class="fs-26 mb-20 col000">{{item.title || item.name}}</view>
          <view class="fs-24 rows rowsm" style="color: #ccc;flex-direction: row-reverse;">{{item.createTime}}</view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        list:[],
		titleType: '',
		limit: {
			pageNum: 1,
			pageSize: 10
		},
		total: 0,
		titleName: null
      };
    },
    onLoad(e) {
	  this.titleType = e.title;
      this.getList();
	  uni.setNavigationBarTitle({
		  title: e.title
	  });
    },
  // 下拉到底部后加载新数据
  onReachBottom() {
    if (this.list.length < this.total) {
      this.limit.pageNum++;
      this.getList();
    }
  },
    methods:{
      getList(){
		const urlType = this.titleType == '通知公告'? 'pronotice/list' : 'prozczx/list';
		const titleType = this.titleType == '通知公告'? 'name' : 'title';
        this.$tools.axiosFromToken('POST',urlType+`?pageNum=${this.limit.pageNum}&pageSize=${this.limit.pageSize}&${[titleType]}=${this.titleName || ''}`,{  },'加载中').then(res => {
          if(res.code != 200) return this.$tools.showtt(res.msg)
		   this.total = res.total;
		   if (this.limit.pageNum == 1) {
		     this.list = [];
		     this.list = res.rows;
		   } else {
		     this.list = [...this.list, ...res.rows];
		   }
        })
      },
	  handleQuery() {
		  this.limit.pageNum = 1;
		  this.getList();
	  }
    }
  }
</script>

<style lang="scss">

</style>
